package com.glory.wxmemsicpda.adapter

import com.chad.library.adapter.base.BaseQuickAdapter
import com.glory.wxmemsicpda.R
import com.glory.wxmemsicpda.base.DataBindBaseViewHolder
import com.glory.wxmemsicpda.bean.MaterialsListBean
import com.glory.wxmemsicpda.databinding.AdapterChangeMaterialsListBinding

class ChangeMaterialsListAdapter(data: List<MaterialsListBean.MaterialsBean?>?) :
    BaseQuickAdapter<MaterialsListBean.MaterialsBean?, DataBindBaseViewHolder>(
        R.layout.adapter_change_materials_list,
        data as MutableList<MaterialsListBean.MaterialsBean?>?
    ) {
    private var mCallBack: CallBack? = null
    override fun convert(helper: DataBindBaseViewHolder, item: MaterialsListBean.MaterialsBean?) {
        val binding: AdapterChangeMaterialsListBinding =
            helper.getDataBinding() as AdapterChangeMaterialsListBinding
        binding.productBean = item
        binding.executePendingBindings()
        binding.tvDownEqp.setOnClickListener {
            mCallBack!!.down(item!!)
        }
        binding.tvChange.setOnClickListener {
            mCallBack!!.change(item!!)
        }
        binding.tvAppend.setOnClickListener{
           val entity: MaterialsListBean.MaterialsBean = item as MaterialsListBean.MaterialsBean
            entity.materiaL_NO = ""
            mCallBack!!.append(entity)
        }
    }

    fun setCallBack(callBack: CallBack) {
        this.mCallBack = callBack
    }

    interface CallBack {
        fun down(materialsBean: MaterialsListBean.MaterialsBean)

        fun change(materialsBean: MaterialsListBean.MaterialsBean)

        fun append(materialsBean: MaterialsListBean.MaterialsBean)

    }
}